﻿@page "/"


<Calendar ValueChanged="@UpdateItems">
    <CellTemplate>
        <td class="@context.DefaultCss">
            <div class="calendar-day">
                <div>@context.CellValue.Day</div>
                <Repeater TItem="Supplierinfo" Items="Items">
                    <ItemTemplate Context="suppliercontext">
                        <div class="d-flex">
                            @if (suppliercontext.Prepaymentdate.Month == context.CellValue.Month && suppliercontext.Prepaymentdate.Day == context.CellValue.Day)
                            {
                                @suppliercontext.Customername
                            }
                        </div>
                    </ItemTemplate>
                </Repeater>
            </div>
        </td>
    </CellTemplate>
</Calendar>
<BootstrapInput @bind-Value="@test" style="margin-top: 1rem;" />




@code {

    private List<Supplierinfo> Items { get; set; }

    private DateTime SupplierinfoDate { get; set; } = DateTime.Today;
    string test;

    protected override async Task OnInitializedAsync()
    {
      await base.OnInitializedAsync();
      Items = _dbContext.Supplierinfos.Where(x => x.Prepaymentdate.Month == SupplierinfoDate.Month && x.Prepaymentdate.Day == SupplierinfoDate.Day).ToList();

    }
   private void UpdateItems(DateTime d)
     {
        Items = _dbContext.Supplierinfos.Where(x => x.Prepaymentdate.Month == d.Month && x.Prepaymentdate.Day == d.Day).ToList();
        StateHasChanged();
        test = d.Day.ToString();
     }

}



